const Router = require('koa-router')
const ItemController = require('../controllers/item.controller')
const jwt = require('../middlewares/jwt.middleware')
const isRole = require('../middlewares/role.middleware')

const router = new Router()
const itemController = new ItemController()
router.prefix('/api/items')

router.get('/', jwt, itemController.findAll)

router.post('/', jwt, isRole(['admin']), itemController.addOne)

router.get('/:id', jwt, itemController.findOne)

router.patch('/:id', jwt, isRole(['admin']), itemController.updateOne)

router.delete('/:id', jwt, isRole(['admin']), itemController.deleteOne)

module.exports = router